<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
    <script type="text/javascript" src="js/jquery-1.42.min.js"></script>
	<script type="text/javascript" src="js/jquery.min.js" ></script>
	<link rel="stylesheet" href="css/base.css" type="text/css"/>
	<link rel="stylesheet" href="css/headbott.css" type="text/css"/>
<script type="text/javascript" src="js/common/url.js"></script>
	
	<link rel="stylesheet" href="admin/css/bootstrap.min.css" />
	<link rel="stylesheet" href="admin/css/dashboard.css" />
</head>

<body>

<%@include file="/WEB-INF/pages/front/common/cf_head.jsp" %>

<div class="modal fade" id="updateNewsModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			        <div class="modal-dialog">
			            <div class="modal-content">
			                <div class="modal-header">
			                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
			                        &times;
			                    </button>
			                    <h4 class="modal-title" id="myModalLabel">
			                        新闻资讯
			                    </h4>
			                </div>
			                <div class="modal-body">
			                    <form class="form-horizontal">
			                        <div class="form-group">
			                            <label for="firstname" class="col-sm-2 control-label">新闻编号</label>
			                            <div class="col-sm-10">
			                                <input id="questionotherid" type="text" class="form-control" readonly="readonly">
			                            </div>
			                        </div>
									<div class="form-group">
			                            <label for="firstname" class="col-sm-2 control-label">新闻标题</label>
			                            <div class="col-sm-10">
			                                <input id="questionothername" type="text" class="form-control" readonly="readonly">
			                            </div>
			                        </div>
			                        <div class="form-group">
			                            <label for="firstname" class="col-sm-2 control-label">新闻内容</label>
			                            <div class="col-sm-10">
			                                <textarea id="questionanswer" class="form-control" readonly="readonly"></textarea>
			                            </div>
			                        </div>
			                        
			                    </form>
			                </div>
			                <div class="modal-footer">
			                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
			                    </button>
			                    
			                </div>
			            </div><!-- /.modal-content -->
			        </div><!-- /.modal -->
			    </div>

<div id="cop">
   <div class="cop-mian">
      <div class="cop_part1">
         <h1 class="page-header">新闻管理</h1>
         <div class="panel panel-default">
         	<div class="panel-heading">
         		<div class="panel-title">
         			新闻列表
         		</div>
         	</div>
         	<div class="panel-body">
         
         		<div class="table-responsive ">
         			<table class="table table-striped table-bordered">
         				<thead>
         					<tr>
         						<th>序号</th>
         						<th>标题</th>
								<th>发布日期</th>
         						<th>操作</th>
         					</tr>
         				</thead>
         				<tbody id="newsList1">
         					
         				</tbody>
         			</table>
         		</div>
         
         		<nav aria-label="Page navigation" class="text-right">
         			<ul class="pagination" id="newsPage">
         
         			</ul>
         		</nav>
         	</div>
         </div>
      </div>
      
   </div>
</div>
<%@include file="/WEB-INF/pages/front/common/cf_bottom.jsp" %> 
		<script type="text/javascript" src="admin/js/jquery1.12.4.min.js"></script>
		<script type="text/javascript" src="admin/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="admin/js/countUp.js"></script>
		<script>
			$(document).ready(function() {
				ajaxPage3(1)
			});
			
			function ajaxPage3(page) {
				$.ajax({
					url: "getAllQuestionOther",
					dataType: "JSON",
					type: "get",
					data: {
						pn: page
					},
					success: function(result) {
						//alert(result.extend["pageInfo"]);
						var pageInfo = result.extend["pageInfo"]
						var msg3=""
						$.each(pageInfo.list, function(i, item) {
							msg3 +="<tr>" +
								"<td>" + (parseInt(pageInfo.pageNum - 1) * 5 + 1 + i) + "</td>" +
								"<td>" + item.questionothername + "</td>" +
								"<td>" + item.questiondate + "</td>" +
								"<td>"+
								"<span onclick='getNewsById("+item.questionotherid+")' class='btn btn-info getNewsById'>详情</span>"+
								"</td>"+
								"</tr>"
						})
						
						$("#newsList1").html(msg3)
						build_page_nav3(pageInfo);
					},
					error: function(err) {}
				})
			}
			
			function emps3(pageNum){
				event.stopPropagation();
				console.log(pageNum)
				ajaxPage3(pageNum)
				
			}
			
			function build_page_nav3(pageInfo2) {
				//上一页
				var previous2 = ""
				if (pageInfo2.hasPreviousPage) {
					previous2 = previous2 + "<li><span onclick='emps3(" +
						(parseInt(pageInfo2.pageNum) - parseInt(1)) + ")' aria-label='Previous'>" +
						"<span aria-hidden='true'>&laquo;</span>" +
						"</span></li>"
				}
				//下一页
				var next2 = ""
				if (pageInfo2.hasNextPage) {
					next2 = next2 + "<li><span onclick='emps3(" +
						(parseInt(pageInfo2.pageNum) + parseInt(1)) +
						")' aria-label='Next'>" +
						"<span aria-hidden='true'>&raquo;</span>" +
						"</span></li>"
				}
				//页数
				var pageNum2 = ""
				$.each(pageInfo2.navigatepageNums, function(i, item) {
						
					if (item == pageInfo2.pageNum) {
						pageNum2 += "<li class='active'><span>" + item + "</span></li>"
					} else {
						pageNum2 += "<li><span class='emps' onclick='emps3(" + item +
							")'>" + item + "</span></li>"
					}
						
						
				})
				
				var msg3 = ""
				msg3 += "<li><span onclick='emps3(" +
					pageInfo2.navigateFirstPage + ")'>首页</span></li>" +
					previous2 + pageNum2 + next2 + "<li><span onclick='emps3(" +
					pageInfo2.navigateLastPage + ")'>末页</span></li>"
					
				
				$("#newsPage").html(msg3);
						
			}
			
			function getNewsById(questionotherid){
				
				$.ajax({
					url:"getNewsById",
					dataType:"JSON",
					data:{questionotherid:questionotherid},
					success:function(data){
						
						$("#questionotherid").val(questionotherid)
						$("#questionothername").val(data.extend["question"].questionothername)
						$("#questionanswer").val(data.extend["question"].questionanswer)
			
					}
				})
			}
			
			$(document).on("click",".getNewsById",function(){
				//弹出模态框
				$("#updateNewsModal").modal({
				   	backdrop:"static"
				});
			});
		</script>
</body>
</html>
    